package com.xpgk.mvc.ddc.ddc_commomUtil;

import java.util.List;

import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.xpgk.annotation.Service;
import com.xpgk.mvc.base.BaseService;
import com.xpgk.mvc.ddc.entity.Business;
import com.xpgk.mvc.ddc.entity.Picture;
import com.xpgk.mvc.ddc.entity.Plate;
import com.xpgk.mvc.ddc.entity.Vehicle;

@Service(name = DDC_CommonUtilService.serviceName)
public class DDC_CommonUtilService extends BaseService{

	@SuppressWarnings("unused")
	private static final Log log = Log.getLog(DDC_CommonUtilService.class);
	public static final String serviceName = "commonUtilService";	
	
	public List<Vehicle> getVehicle() {
		String sql = "SELECT * from DDC_VEHICLE";
		List<Vehicle> vehicle = Vehicle.dao.find(sql);
		return vehicle;
	}
	
	public List<Vehicle> getVehicleByCLSBDH(String CLSBDH) {
		String sql = "SELECT * from DDC_VEHICLE where CLSBDH = ?";
		List<Vehicle> vehicle = Vehicle.dao.find(sql,CLSBDH);
		return vehicle;
	}
	
	public List<Business> getBusiness() {
		String sql = "SELECT * from DDC_BUSINESS WHERE status < 4";
		List<Business> business = Business.dao.find(sql);
		return business;
	}
	
	
	public List<Plate> getPlate() {
		String sql = "SELECT * from DDC_PLATE Where status = 1";
		List<Plate> plate = Plate.dao.find(sql);
		return plate;
	}
	
	public List<Plate> getPlateByHPHM(String HPHM) {
		String sql = "SELECT * from DDC_PLATE Where HPHM = ?";
		List<Plate> plate = Plate.dao.find(sql,HPHM);
		return plate;
	}
	
	public List<Picture> getPicture(String businessids) {
		String sql = "SELECT * from DDC_PICTURE WHERE BUSINESSIDS = ? ORDER BY PICTURENAME";
		List<Picture> mm = Picture.dao.find(sql,businessids);
		return mm;
	}
	
	public Picture getPicture(String businessids,String picturename) {
		String sql = "SELECT * from DDC_PICTURE WHERE BUSINESSIDS = ? AND PICTURENAME = ?";
		Picture P = Picture.dao.findFirst(sql,businessids,picturename);
		return P;
//		List<Record> list=Db.find("SELECT * from DDC_PICTURE WHERE BUSINESSIDS = ? AND PICTURENAME = ?",businessids,picturename);
//		Record r = null;
//		if(list!=null&&list.size()>0){
//			 r = list.get(0);
//		 }
//		renderJson(r);
	}
	
}
